﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class NewDashboard : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {        
        
        if (!IsPostBack)
        {
            
            if (Session["Person"] == null)
            {
                Session["Person"] = loggedperson.ID;
            }
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" +  Session["Person"] + "')</SCRIPT>");
        }


        //if (!IsPostBack)
        //{
        //    if (Session["Person"] == null)
        //    {
        //        loggedperson.Text = "Welcome";
        //    }
        //    else
        //    {
        //        loggedperson.Text = Session["Person"].ToString();
                
        //        System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" + loggedperson.Text + "')</SCRIPT>");
        //    }
        //}

        //string user = (string)(Session["Person"]);
        //System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" + user + "')</SCRIPT>");
        //if (Session["Person"] != null)
        //{
        //    loggedperson.Text = user;
        //    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('" + loggedperson.Text + "')</SCRIPT>");
        //} 

         
        if (Session["Authentication"] == null)
        {
            Response.Redirect("~/AdminLogin.aspx");
        }
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
        Response.Cache.SetNoStore();

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session.Clear();
        if (Request.Cookies["MyCookie"] != null)
        {
            var c = new HttpCookie("MyCookie");
            c.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(c);
        }

        Session.Abandon();
        Response.Cookies.Clear();

        Response.Redirect("AdminLogin.aspx", true);     
    

       
    }
}